package com.yijiu.trb;

import android.app.AlertDialog;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.yijiu.resource.CacheData;
import com.yijiu.view.DownLoadImage;

public class MyBankCardActivity extends BTitleActivity
{
	/**
	 * 未实名认证提示窗口
	 */
	public AlertDialog dialog;

	@Override
	public void onCreate(Bundle savedInstanceState)
	{
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_my_bank_card);
		initWidget();
	}

	@Override
	protected void initWidget()
	{
		titleView.setText("我的银行卡");
		LinearLayout llayoutBankInfo = (LinearLayout) findViewById(R.id.llayout_my_card_has_card);
		TextView noCard = (TextView) findViewById(R.id.tv_my_card_no_card);
		ImageView bankIcon = (ImageView) findViewById(R.id.iv_my_bank_card_icons);
		TextView bankCard = (TextView) findViewById(R.id.iv_my_bank_card_infos);
		String numStr = CacheData.BANK_CARD_NUMBER;
		if (numStr.equals("") || numStr == null || numStr.equals("null"))
		{
			llayoutBankInfo.setVisibility(View.GONE);
			noCard.setVisibility(View.VISIBLE);
		}
		else
		{
			llayoutBankInfo.setVisibility(View.VISIBLE);
			noCard.setVisibility(View.GONE);
			new DownLoadImage(bankIcon).execute(CacheData.BANK_ICON_URL);
			numStr = numStr.substring(numStr.length() - 4, numStr.length());
			bankCard.setText("****  ****  ****  " + numStr);
		}
	}

	@Override
	protected void onActivityResult(int requestCode, int resultCode, Intent data)
	{
		super.onActivityResult(requestCode, resultCode, data);
		if (resultCode == RESULT_OK && requestCode == 0)
		{
			Intent intent = getIntent();
			setResult(RESULT_OK, intent);
			finish();
		}
	}

	public void myCardClick(View v)
	{
		int id = v.getId();
		switch (id)
		{
			case R.id.tv_my_card_no_card:
			case R.id.btn_my_bank_card_add:
				startActivityForResult(new Intent(this, AddBankCardOther.class), 0);
				break;
			default:
				break;
		}
	}
}
